from technology.models import Technology
from pms.common.utils import flatten_view


def update_technology_by_view(tid, view):
    """ 根据前端视图更新技术对象 """
    tech = Technology.objects.get(id=tid)
    argv = flatten_view(view, {
        'name': 'name',
        'detail': 'detail'
    })
    tech.__dict__.update(**argv)
    tech.save()
    return tech
